package com.social.controller;

import com.alibaba.fastjson.JSONObject;
import com.social.entity.WorkexPerience;
import com.social.service.workexPerience.WorkexPerienceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
/*
* 工作经验控制层
* */
@Controller
@RequestMapping(value = "/workexPerience")
public class WorkexPerienceController {
    @Autowired
    private WorkexPerienceService workexPerienceService;
    @RequestMapping(value = "/list",produces = "application/json;charset=UTF-8")
    public String list(String houseKeeperId){
        List<WorkexPerience> workexPerienceList= workexPerienceService.selectByHouseKeeperId(houseKeeperId);
        JSONObject result = new JSONObject();
        result.put("msg", "ok");
        if(workexPerienceList.size()>0){
            result.put("code", 0);
        }else {
            result.put("code", 1);
        }
        result.put("method", "list");
        result.put("datas",workexPerienceList);
        return result.toJSONString();
    }
    @RequestMapping(value = "/add",produces = "application/json;charset=UTF-8")
    public String addWorkexPerience(WorkexPerience WorkexPerience){
        int count = workexPerienceService.addWorkexPerience(WorkexPerience);
        JSONObject result = new JSONObject();
        result.put("msg", "ok");
        if(count>0){
            result.put("code", 0);
        }else {
            result.put("code", 1);
        }
        result.put("method", "list");
        return result.toJSONString();
    }
}
